<?php
// +---------------------------------------------------------------------+
// | OneBase    | [ WE CAN DO IT JUST THINK ]                            |
// +---------------------------------------------------------------------+
// | Licensed   | http://www.apache.org/licenses/LICENSE-2.0 )           |
// +---------------------------------------------------------------------+
// | Author     | 王勇程 <laughskydragon@qq.com>                         |
// +---------------------------------------------------------------------+
// | Repository | https://gitee.com/Bigotry/OneBase                      |
// +---------------------------------------------------------------------+

namespace app\common\validate;

/**
 * 提现验证器
 */
class Withdraw extends ValidateBase
{
    
    // 验证规则
    protected $rule = [
        'id'            => 'require|integer|gt:0',
        'user_id'       => 'require|integer|gt:0',
        'amount'        => 'require|float|gt:0',
        'fee'           => 'float|egt:0',
        'actual_amount' => 'float|gt:0',
        'withdraw_no'   => 'require|length:1,32',
        'withdraw_status' => 'require|in:0,1,2,3',
        'status'        => 'in:0,1',
        'remark'        => 'length:0,255',
        'bank_name'     => 'length:0,50',
        'bank_account'  => 'length:0,50',
        'account_name'  => 'length:0,50',
        'alipay_account'=> 'length:0,50',
        'wechat_account'=> 'length:0,50',
        'withdraw_type' => 'in:1,2,3',
    ];

    // 验证提示
    protected $message = [
        'id.require'            => '提现ID不能为空',
        'id.integer'            => '提现ID必须为整数',
        'id.gt'                 => '提现ID必须大于0',
        'user_id.require'       => '用户ID不能为空',
        'user_id.integer'       => '用户ID必须为整数',
        'user_id.gt'            => '用户ID必须大于0',
        'amount.require'        => '提现金额不能为空',
        'amount.float'          => '提现金额必须为数字',
        'amount.gt'             => '提现金额必须大于0',
        'fee.float'             => '手续费必须为数字',
        'fee.egt'               => '手续费不能为负数',
        'actual_amount.float'   => '实际到账金额必须为数字',
        'actual_amount.gt'      => '实际到账金额必须大于0',
        'withdraw_no.require'   => '提现单号不能为空',
        'withdraw_no.length'    => '提现单号长度不能超过32个字符',
        'withdraw_status.require' => '提现状态不能为空',
        'withdraw_status.in'    => '提现状态值不正确',
        'status.in'             => '记录状态值不正确',
        'remark.length'         => '备注长度不能超过255个字符',
        'bank_name.length'      => '银行名称长度不能超过50个字符',
        'bank_account.length'   => '银行账号长度不能超过50个字符',
        'account_name.length'   => '账户姓名长度不能超过50个字符',
        'alipay_account.length' => '支付宝账号长度不能超过50个字符',
        'wechat_account.length' => '微信账号长度不能超过50个字符',
        'withdraw_type.in'      => '提现方式不正确',
    ];

    // 应用场景
    protected $scene = [
        'add'       => ['user_id', 'amount', 'withdraw_type'],
        'edit'      => ['id', 'amount', 'withdraw_status'],
        'review'    => ['id', 'withdraw_status'],
        'apply'     => ['user_id', 'amount', 'withdraw_type'],
        'query'     => ['withdraw_no'],
        'batch'     => ['withdraw_status'],
    ];
}